#ifndef CNSROOTCOMDEFINITION_H
#define CNSROOTCOMDEFINITION_H

#include "cnsMacroGlobal.h"
#include <QVariant>
class CnsDefaultComFactory;

class CnsRootComDefinition
{
public:
    CnsRootComDefinition(){
    }
    CnsRootComDefinition(const QString *dirFullPath): _dirFullPath(dirFullPath)
      , _defFullPath(nullptr), _inheritFullPath(nullptr)
    {}

    QString getName() const noexcept
    { return _name; }
    void setName(const QString &name) noexcept
    {
        _name = name;
    }

    QString getSystemName() const noexcept
    { return _systemName; }
    void setSystemName(const QString &systemName) noexcept
    { _systemName = systemName; }

    const QString& getNamespace() const noexcept
    { return _nameSpace; }
    void setNamespace(const QString &nameSpace) noexcept
    { _nameSpace = nameSpace; }

    const QString* getDefFullPath() const noexcept
    { return _defFullPath; }
    void setDefFullPath(const QString *defFullPath) noexcept
    { _defFullPath = defFullPath; }

    const QString* getDirFullPath() const noexcept
    { return _dirFullPath; }
    void setDirFullPath(const QString *dirFullPath) noexcept
    { _dirFullPath = dirFullPath; }

    QVariantHash getProperties() const noexcept
    { return _properties; }
    void addProperty(const QString &name, const QVariant &value) noexcept
    { _properties.insert(name, value); }
    
    QVariantList getChildren() const noexcept
    { return _children; }
    void addChildren(const QVariant &val) noexcept
    { _children.append(val); }

    //defPath suport these formats below:
    //defPath=filename/namespace/defName
    //defPath=filename//defName
    void setInheritPath(const QString &inheritPath)
    {
        _inheritPath = inheritPath;
    }

    void setInheritFullPath(const QString *inheritFullPath)
    {
        _inheritFullPath = inheritFullPath;
    }

    const QString& getInheritPath()
    {
        return _inheritPath;
    }

    const QString *getInheritFullPath(CnsDefaultComFactory *registry) noexcept;

//    QString *convertObjFullPath(const QString &objName)
//    {
//        return new QString(*_defFullPath + objName);
//    }

protected:
    QString _name;
    QString _systemName;
    QVariantHash _properties;
    QVariantList _children;
    QString _nameSpace;
    QString _inheritPath;
    const QString *_dirFullPath;
    const QString *_defFullPath;
    const QString *_inheritFullPath;
};

class CnsComDefinition : public CnsRootComDefinition
{
public:
    QString getObjName() const noexcept
    { return _objName; }
    void setObjName(QString &objName) noexcept
    { _objName = objName; }
protected:
    QString _objName;
};

CNS_DECL_POINTER(CnsRootComDefinition)
CNS_DECL_POINTER(CnsComDefinition)

#endif
